package com.lu.lupicturebackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lu.lupicturebackend.api.aliyunai.model.CreateOutPaintingTaskResponse;
import com.lu.lupicturebackend.model.dto.picture.*;
import com.lu.lupicturebackend.model.entity.Picture;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lu.lupicturebackend.model.entity.User;
import com.lu.lupicturebackend.model.vo.PictureVO;
import org.springframework.scheduling.annotation.Async;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author 86186
 * @description 针对表【picture(图片)】的数据库操作Service
 * @createDate 2025-05-30 10:36:16
 */
public interface PictureService extends IService<Picture> {


    /**
     * 上传图片
     *
     * @param inputResource
     * @param pictureUploadRequest
     * @param loginUser
     * @return
     */
    PictureVO uploadPicture(Object inputResource,
                            PictureUploadRequest pictureUploadRequest,
                            User loginUser);

    /**
     * 获取图片查询
     *
     * @param pictureQueryRequest
     * @return
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);

    /**
     * 图片返回封装，进行脱敏（单条）
     *
     * @param picture
     * @param request
     * @return
     */
    PictureVO getPictureVO(Picture picture, HttpServletRequest request);

    /**
     * 分页获取图片封装
     *
     * @param picturePage
     * @param request
     * @return
     */
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);

    /**
     * 图片校验
     *
     * @param picture
     */
    public void validPicture(Picture picture);


    /**
     * 图片审核
     *
     * @param loginUser
     * @param pictureReviewRequest
     */
    void doPictureReview(PictureReviewRequest pictureReviewRequest, User loginUser);

    /**
     * 图片填充审核参数
     *
     * @param picture
     * @param loginUser
     */
    void fillReviewParams(Picture picture, User loginUser);

    /**
     * 批量抓取图片
     *
     * @param pictureUploadByBatchRequest
     * @param loginUser
     */
    Integer batchUploadPicture(PictureUploadByBatchRequest pictureUploadByBatchRequest, User loginUser);

    /**
     * 清理图片
     *
     * @param oldPicture
     * @return
     */
    void deletePicture(Picture oldPicture);

    /**
     * 校验空间图片的权限
     *
     * @param picture
     * @param loginUser
     */
    void checkPictureAuth(Picture picture, User loginUser);

    /**
     * 删除图片
     *
     * @param id
     * @param loginUser
     */
    void deletePicture(Long id, User loginUser);

    /**
     * 编辑图片
     *
     * @param pictureEditRequest
     * @param request
     */
    void editPicture(PictureEditRequest pictureEditRequest, HttpServletRequest request);

    /*
     * 删除空间下的图片
     */
    @Async
    void deleteSpaceAndPicture(long spaceId, User loginUser);

    /**
     * 根据颜色搜索
     */
    List<PictureVO> searchPictureByColor(Long spaceId, String picColor, User loginUser);

    /**
     * 批量编辑图片
     * @param pictureEditByBatchRequest
     * @param loginUser
     */
    void editPictureByBatch(PictureEditByBatchRequest pictureEditByBatchRequest, User loginUser);

    /**
     * 创建图片外绘任务
     * @param createPictureOutPaintingTaskRequest
     * @param loginUser
     * @return
     */
    CreateOutPaintingTaskResponse createPictureOutPaintingTask(CreatePictureOutPaintingTaskRequest createPictureOutPaintingTaskRequest, User loginUser);
}
